package com.xuan.webfinally.mapper;

import com.xuan.webfinally.entity.SlopeFencenetData;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xuan.webfinally.entity.pax2;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 边坡防护网监测数据表 Mapper 接口
 * </p>
 *
 * @author gyuxuan
 * @since 2025-09-08
 */
public interface SlopeFencenetDataMapper extends BaseMapper<SlopeFencenetData> {

    @Select("SELECT device_sn,monitor_id, x_tilt_angle, y_tilt_angle, z_tilt_angle, " +
            "x_acceleration, y_acceleration, z_acceleration, create_time, " +
            "update_time, x_tilt_angle_change, y_tilt_angle_change, " +
            "z_tilt_angle_change, xy_tilt_angle_change " +
            "FROM (" +
            "    SELECT *, " +
            "    ROW_NUMBER() OVER (PARTITION BY device_sn ORDER BY update_time DESC) AS rn " +
            "    FROM slope_fencenet_data " +
            "    WHERE slope_id = #{deptId} " +
            ") t " +
            "WHERE rn = 1")
    List<pax2> getPax2(String deptId);

}
